#include "widget.h"
#include "ui_widget.h"
#include <QPainter>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
    // (void)event;
    // QPainter painter(this);
    // QPixmap pixmap(":/mei.jpg");
    // painter.drawPixmap(0, 0, pixmap);
    // //painter.drawPixmap(100, 100, 500, 300, pixmap);

    // 实例化画家对象
    QPainter painter(this);
    // 让旋转的中心为(100,100)
    painter.translate(100, 100);
    painter.rotate(90); // 顺时针旋转90度
    painter.translate(-100, -100); // 恢复坐标
    // 画.drawPixmap(图片
    QPixmap pixmap(":/mei.jpg");
    painter.drawPixmap(0, 0, pixmap);
}

